<template>
  <div class="logcontainer">
    <vab-query-form>
      <vab-query-form-left-panel :span="24">
        <el-form :inline="true" :model="queryForm" @submit.native.prevent>
          <el-form-item label="账号:">
            <el-input
              v-model.trim="queryForm.username"
              placeholder="请输入账号"
              clearable
            />
          </el-form-item>
          <el-form-item label="周期:">
            <el-date-picker
              v-model="value1"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            ></el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button icon="el-icon-search" type="primary" @click="queryData">
              查询
            </el-button>
          </el-form-item>
        </el-form>
      </vab-query-form-left-panel>
    </vab-query-form>

    <el-table
      v-loading="listLoading"
      :data="list"
      :element-loading-text="elementLoadingText"
      @selection-change="setSelectRows"
    >
      <el-table-column show-overflow-tooltip type="selection"></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="optType"
        label="操作类型"
      ></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="optUserName"
        label="操作人"
      ></el-table-column>
      <el-table-column show-overflow-tooltip prop="optResult" label="执行结果">
        <template slot-scope="scope">
          <label
            v-if="scope.row.status == '2'"
            class="text-sign danger"
          ></label>
          <label v-else class="text-sign success"></label>
          {{ scope.row.statusLabel }}
        </template>
      </el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="updated"
        label="操作时间"
      ></el-table-column>
      <el-table-column
        show-overflow-tooltip
        prop="description"
        label="备注"
      ></el-table-column>
    </el-table>
    <el-pagination
      background
      :current-page="queryForm.pageNo"
      :page-size="queryForm.pageSize"
      :layout="layout"
      :total="total"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
    ></el-pagination>
  </div>
</template>

<script>
//import { getList, doDelete } from '@/api/logManagement'

export default {
  name: 'LogManagement',
  components: {},
  data() {
    return {
      list: null,
      listLoading: true,
      layout: 'total, sizes, prev, pager, next, jumper',
      total: 0,
      selectRows: '',
      elementLoadingText: '正在加载...',
      queryForm: {
        pageNo: 1,
        pageSize: 10,
        username: '',
      },
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    setSelectRows(val) {
      this.selectRows = val
    },
    handleSizeChange(val) {
      this.queryForm.pageSize = val
      this.fetchData()
    },
    handleCurrentChange(val) {
      this.queryForm.pageNo = val
      this.fetchData()
    },
    queryData() {
      this.queryForm.pageNo = 1
      this.fetchData()
    },
    async fetchData() {
      this.listLoading = true
      //const { data, totalCount } = await getList(this.queryForm)
      this.list = []
      this.total = 0
      setTimeout(() => {
        this.listLoading = false
      }, 300)
    },
  },
}
</script>
<style lang="scss" scoped>
.el-table__body {
  .el-link:last-child {
    margin-left: 10px;
  }
}
.logcontainer {
  padding: 10px;
}
</style>
